//@ANDROIDONLYFILE@//

//@ANDROIDONLYFILE@//

package com.bluetane.android;

import com.bluetane.android.BluetaneEvent.BluetaneEventType;

import android.app.Activity;
import android.content.Intent;

public class ActivityListener extends Activity
{	
	private static final int ENABLE_BLUETOOTH = 1;
    private static final int ENABLE_DISCOVERY = 2;
    private BluetaneEventSource eventSource;
    private BtLocalDevice localDevice;
    
	public ActivityListener(BluetaneEventSource startEventSource, BtLocalDevice startLocalDevice)
	{
		localDevice = startLocalDevice;
		eventSource = startEventSource;
	}
	
	public void onActivityResult(int requestCode, int resultCode, Intent data)
    {
        if (requestCode == ENABLE_BLUETOOTH)
        {
            switch (resultCode)
            {
                case Activity.RESULT_OK:
                    eventSource.fireEvent(new BluetaneEvent(localDevice, BluetaneEventType.BluetoothActivated, "Bluetooth Activated"));
                break;
                case Activity.RESULT_CANCELED:
                    //eventSource.fireEvent(new BluetaneEvent(LocalDevice, ));
                break;
            }
        }
        if (requestCode == ENABLE_DISCOVERY)
        {
            switch (resultCode)
            {
                case Activity.RESULT_OK:
                    eventSource.fireEvent(new BluetaneEvent(localDevice, BluetaneEventType.MadeDiscoverable, "Made Discoverable"));
                break;
                case Activity.RESULT_CANCELED:
                    //eventSource.fireEvent(new BluetaneEvent(localDevice));
                break;
            }
        }
    }
}
